package com.wicket.okrapp.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wicket.okrapp.base.service.MRelatedSetService;
import com.wicket.okrapp.base.service.dto.req.QueryBatchRelatedSetDetailReq;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.common.util.CommonFunctionHelper;
import com.wicket.okrapp.dal.mapper.mbg.RelatedSetMapper;
import com.wicket.okrapp.dal.po.mbg.RelatedSet;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 *
 * @version 1.0
 */
@Service
public class MRelatedSetServiceImpl
        extends ServiceImpl<RelatedSetMapper, RelatedSet>
        implements MRelatedSetService {

    @Autowired
    RelatedSetMapper relatedSetMapper;

    /**
     * 3-3-09-03查批次相关设置[2998]
     */
    @Trace(operationName = "3-3-09-03查批次相关设置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public RelatedSet queryBatchRelatedSetDetail(QueryBatchRelatedSetDetailReq reqDto) {

        try {

            Map<String, Object> columnMap = CommonFunctionHelper.objectToMap(reqDto);
            List<RelatedSet> retList = (List<RelatedSet>) super.listByMap(columnMap);
            if (retList == null || retList.size() <= 0) return null;
            RelatedSet ret = retList.get(0);

            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }

    }
}
